package com.zhiyou100.day05;

/**
 * 冒泡法排序
 * 每次循环将最大的放到最右边
 */
public class BubbleSort {
    public static void main(String[] args) {
        int [] a = {5, 14, 3, 9, 6, 30};
        for(int i=0;i<a.length-1;i++){
            for(int j=0; j<a.length-1-i; j++){
                int temp;
                if(a[j] > a[j+1]){
                    temp = a[j+1];
                    a[j+1] = a[j];
                    a[j] = temp;
                }
            }
        }
        for(int i=0;i<a.length;i++){
            System.out.println(a[i] + " ");
        }
    }
}
